<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>请假登记申请表 </title>
    <link rel="stylesheet" href="../static/css/reset.css">
    <link rel="stylesheet" href="../static/plus/eleme.css">
    <link rel="stylesheet" href="../static/css/style_xia.css">
</head>
<body>
<div id="app" class="car-apply apply-vacate">
    <mt-header fixed title="请假登记申请表">
        <mt-button slot="left" icon="back" @click="goBack"></mt-button>
        <mt-button slot="right" icon="more" @click="sheetVisible = true;"></mt-button>
    </mt-header>
    <section class="content">
        <div class="item">
            <label class="label" for="">部门</label>
            <input class="text" type="text" v-model="apply.department" disabled>
        </div>
        <div class="item">
            <label class="label" for="">申请人</label>
            <input class="text" type="text" v-model="apply.applicant" disabled>
        </div>
        <div class="item">
            <label class="label" for="">请假开始时间</label>
            <input v-model="apply.startTime" class="text" @click="open('picker1')">
        </div>
        <div class="item">
            <label class="label" for="">请假结束时间</label>
            <input v-model="apply.endTime" class="text" @click="open('picker2')">
        </div>
        <div class="item">
            <label class="label" for="">申请时间</label>
            <input class="text" type="text" v-model="apply.applyTime" disabled>
        </div>
        <div class="item select-num" @click="showVacateDate = true">
            <label class="label" for="">请假天数</label>
            <input class="text" type="text" v-model="apply.dataNumText">
        </div>
        <div class="item select-type" @click="reasonShowBtnModel = true">
            <label class="label" for="">请假类别</label>
            <span class="c-666" v-text="apply.type"></span>
        </div>
        <div class="item reason">
            <label class="label" for="">请假事由</label>
            <textarea name="" id="" rows="5" v-model="apply.reason"></textarea>
        </div>
        <div class="item" v-show="apply.dataNum > 1">
            <label class="label" for="">病假条</label>
            <div class="upload-box">
                <img src="../static/images/icon/uoload.png" class="upload-icon" alt="">
                <input @change="getFile($event)" class="text file-load" type="file" multiple>
                <span v-if="filesArr.length>0" class="file-num">{{filesArr.length}}个附件</span>
                <p v-if="filesArr.length>0" v-for="(item,index) in filesArr" v-text="item" :key="index"
                   @click="delFile(index)" class="file-name"></p>
            </div>
        </div>
        <div class="item notice">
            <p>*请假超过1天须分管领导批准。</p>
            <p>*请假天数 请慎重填写，作为考勤依据。</p>
            <p>*病假大于等于1天需上传病假条的附件。</p>
        </div>
        <div class="item send-btn">
            <button class="btn" @click="applyBth">提交</button>
        </div>

        <!--开始时间选择器-->
        <mt-datetime-picker
                ref="picker1"
                type="datetime"
                :start-date="startDate"
                @confirm="handleConfirmS">
        </mt-datetime-picker>

        <!--结束时间选择器-->
        <mt-datetime-picker
                ref="picker2"
                type="datetime"
                :start-date="startDate"
                @confirm="handleConfirmE">
        </mt-datetime-picker>

        <!--数量选择器-->
        <div class="custom-picker" v-show="showVacateDate">
            <transition name="btnModel">
                <div class="picker-box">
                    <div class="btns">
                        <button @click="showVacateDate = false">取消</button>
                        <button @click="showVacateDate = false">确认</button>
                    </div>
                    <mt-picker :slots="numberSlot" @change="onNumberChange" :visible-item-count="3"></mt-picker>
                </div>
            </transition>
        </div>

        <!--事由选择器-->
        <div class="custom-picker" v-show="reasonShowBtnModel">
            <transition name="btnModel">
                <div class="picker-box">
                    <div class="btns">
                        <button @click="reasonShowBtnModel = false">取消</button>
                        <button @click="reasonShowBtnModel = false">确认</button>
                    </div>
                    <mt-picker :slots="reasonSlot" @change="onReasonChange" :visible-item-count="3"></mt-picker>
                </div>
            </transition>
        </div>

        <!--active sheet-->
        <mt-actionsheet
                :actions="actions"
                v-model="sheetVisible"
                close-on-click-modal>
        </mt-actionsheet>
    </section>
    <v-footer></v-footer>
    <div class="loading" v-show="isShow">
        <mt-spinner :type="0" :size="60"></mt-spinner>
    </div>
</div>
</body>
<script src="../static/plus/vue.js"></script>
<script src="../static/plus/eleme.js"></script>
<script src="../static/js/common.js"></script>
<script>
    window.onload = function () {
        var vm = new Vue({
            el: '#app',
            data: {
                showVacateDate: false,
                reasonShowBtnModel: false,
                isShow: true,
                sheetVisible: false,
                startDate: new Date(),
                isShowBtnModel: false,
                actions: [],
                apply: {
                    department: '综合部', // 部门
                    applicant: '测试', // 申请人
                    applyTime: '2018-02-08 21:12',
                    type: '事假',
                    dataNum: null,
                    dataNumText: '',
                    startTime: '',
                    endTime: '',
                    reason: '原因'
                },
                filesArr: [],
                numberSlot: [
                    {
                        flex: 1,
                        values: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1],
                        className: 'slot1'
                    },
                    {
                        divider: true,
                        content: '（天--时）',
                        className: 'slot2'
                    },
                    {
                        flex: 1,
                        values: [
                            0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1,
                            1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2,
                            2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3
                        ],
                        className: 'slot3'
                    }
                ],
                reasonSlot: [
                    {
                        flex: 1,
                        values: ['事假', '病假', '休假', '探亲假', '产假', '护理假', '丧假', '婚假', '产检假', '其他'],
                        className: 'slot1'
                    }
                ]

            },
            methods: {
                onNumberChange(picker, values) {
                    var day = values[0];
                    var h = values[1];
                    this.apply.dataNum = day;
                    this.apply.dataNumText = day+"天"+' '+h+"小时";
                },
                onReasonChange(picker, values) {
                    this.apply.type = values[0];
                },
                handleConfirmS(value) {
                    this.apply.startTime = getDateTime(value);
                },
                handleConfirmE(value) {
                    this.apply.endTime = getDateTime(value);
                },
                open(picker) {
                    this.$refs[picker].open();
                },
                goBack() {
                    history.go(-1);
                },
                applyBth() {

                },
                selectNum() {

                },
                selectType() {

                },
                getFile(event) {
                    var files = event.target.files;
                    for (let i = 0; i < files.length; i++) {
                        this.filesArr.push(files[i].name)
                    }
                },
                delFile(index) {
                    this.filesArr.splice(index, 1);
                },
                getBtnCode(index) {
                    console.log('点击了第' + index + '个按钮');
                }
            },
            created() {
            },
            mounted() {
                setSectionHeight();
                this.isShow = false;
                this.actions = [
                    {name: '保存', method: this.getBtnCode},
                    {name: '提交', method: this.getBtnCode},
                    {name: '终止', method: this.getBtnCode},
                    {name: '查看流程图', method: this.getBtnCode},
                    {name: '删除', method: this.getBtnCode},
                    {name: '完成', method: this.getBtnCode}
                ]
            }
        });
    }
</script>
</html>